﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace FigureDraw
{
    public class ConditionSymbolActivity : ConditionSymbol
    {
        public ConditionSymbolActivity(StorageDevice sd)
            : base(sd)
        {
            this.strInfor = "Condition";
        }

        public ConditionSymbolActivity(StorageDevice sd, Infor infor)
            : base(sd, infor)
        {
            
        }

        public override void DrawToDevice(Form form)
        {
            this.R = 255;
            this.G = 0;
            this.B = 0;
            this.LineWidth = 5;
            this.KhoiTaoTruocKhiVe();

            int width = 170;  //Chiều dài cạnh AB của hình bình hành
            int height = 60;

            //Cố định kích thước hình
            this.EndPoint = new Point(this.BeginPoint.X + width, this.BeginPoint.Y + height);


            Point A, B, C, D; // Các đỉnh của Thoi. 
            /*
             *    B
             * A      C
             *    D
             * 
             * */
            A = new Point(this.BeginPoint.X, (int)(this.BeginPoint.Y + height / 2));
            B = new Point((int)(this.BeginPoint.X + width / 2), this.BeginPoint.Y);
            C = new Point(this.EndPoint.X, (int)(this.EndPoint.Y - height / 2));
            D = new Point((int)(this.BeginPoint.X + width / 2), this.EndPoint.Y);

            //Thêm RichTexBox vào Form
            //Point dt = new Point();
            //dt.X = AB / 5;
            //dt.Y = height / 5;
            //float fontSize = fontSize = (float)(height - height / 2 - height / 4);
            //if (fontSize < 1)
            //    fontSize = 1;

            this.rtbInfor.ReadOnly = false;
            this.rtbInfor.Font = new Font("Arial", 12, FontStyle.Bold);
            this.rtbInfor.BorderStyle = BorderStyle.None;
            this.rtbInfor.Text = this.strInfor;
            this.rtbInfor.BackColor = System.Drawing.SystemColors.Menu;
            this.rtbInfor.SelectionAlignment = HorizontalAlignment.Center;
            this.rtbInfor.Location = new Point(BeginPoint.X + width / 4 + 3, BeginPoint.Y + height / 4 + 3);
            this.rtbInfor.Size = new System.Drawing.Size(width - width / 2 - 6, height - height / 2 - 6);
            this.rtbInfor.Visible = true;
            if (form != null)
                form.Controls.Add(this.rtbInfor);
            else
                this.StorageDevice.drawString(this.rtbInfor.Text, this.rtbInfor.Font, this.rtbInfor.Location);


            this.StorageDevice.drawLine(A.X, A.Y, B.X, B.Y);
            this.StorageDevice.drawLine(B.X, B.Y, C.X, C.Y);
            this.StorageDevice.drawLine(C.X, C.Y, D.X, D.Y);
            this.StorageDevice.drawLine(A.X, A.Y, D.X, D.Y);
        }
    }
}
